import {View, Text, ScrollView} from "@tarojs/components";
import React, {useEffect, useRef, useState} from "react";
import {NoticeModel} from "@/common/apis/model";
import {getNoticeList} from "@/common/apis/home_datasource";
import LogUtils from "@/utils/log";
import {Cell, CellGroup, Empty} from "@antmjs/vantui";
import Utils from "@/utils/common";
import StyleUtils from "@/utils/style_utils";

definePageConfig({
  navigationBarTitleText: '团队详情',
})

export default function Group_detail() {
  const [items, setItems] = useState<NoticeModel[]>()

  useEffect(() => {
    getNoticeList().then((res) => {
      setItems(res)
    })
    return () => {
      LogUtils.info("Page1", "Page1")
    }
  }, []);

  const maxLinesStyle = useRef(StyleUtils.getMaxLines(1));

  return (
    <View style={{
      display: 'flex',
      flexDirection: 'column',
      height: '100VH',
      paddingBottom: '50px',
      boxSizing: 'border-box',
      backgroundColor: '#f2f2f2',
    }}
    >
      <View>
        <CellGroup title={'团队信息'} inset>
          <Cell title='团队名称' value='团队名称'/>
          <Cell title='团队资金' value='100'/>
        </CellGroup>
      </View>
     <View  >
       <CellGroup title={'团队成员'} style={{flex: 1, position: 'relative', overflow: 'hidden',marginTop: '10px'}} inset>
         <ScrollView scrollY style={{height: '100%', boxSizing: 'border-box'}}>
           {items && !Utils.isEmpty(items) ? items.map((e, i) => {
             return <View key={i}><Cell renderTitle={<Text style={maxLinesStyle.current}>{e.title}</Text>}/></View>
           }) : <Empty description='暂无数据'/>}
         </ScrollView>
       </CellGroup>
     </View>
    </View>
  )
}


